<!DOCTYPE html>
<html lang="zh-Hans">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>lesson3</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="root"></div>
</body>

<script>
    Vue.createApp({
        data() {
            return {
                inputValue: '',
                list: []//['hello', 'my', 'little', 'pony']
            }
        },
        methods: {
            handleAddItem() {
                this.list.push(this.inputValue)
                this.inputValue = ''
            }
        },
        template: `
            <div>
                <input v-model="inputValue"/>
                <button v-on:click="handleAddItem">增加</button>
                <ul>
                    <li v-for="(item, index) of list">{{item}}</li>
                </ul>
            </div>
        `
    }).mount('#root');
</script>

</html>